package com.aglhz.nature.fragment;

import java.util.LinkedList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import com.aglhz.nature.R;
import com.aglhz.nature.constants.ServerAPI;
import com.aglhz.nature.modle.CodeBean;
import com.aglhz.nature.utils.AsyncHttpCilentUtil;
import com.aglhz.nature.utils.Constants;
import com.aglhz.nature.utils.MD5;
import com.aglhz.nature.view.LoginActivity;
import com.aglhz.nature.view.MainActivity;
import com.aglhz.nature.view.PayActivity;
import com.aglhz.nature.view.SecondHomeWebActivity;
import com.aglhz.nature.view.ShopActivity;
import com.aglhz.nature.wxapi.WXPayEntryActivity;
import com.google.gson.Gson;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.TextHttpResponseHandler;
import com.tencent.mm.sdk.modelpay.PayReq;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

import cz.msebera.android.httpclient.Header;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class ShopCartFragment extends Fragment {
	
	private WebView shopcartWebView;
	private SharedPreferences sharedPreferences;  
	private String token;
	private String nor_token;
	private String wx_token;
	private CodeBean codeBean;
	
	private String url;
	private int appType=2;
	private IWXAPI api;
	Intent intent;
//	private MainActivity mainActivity;
	@Override
	public View onCreateView(LayoutInflater inflater,
			 ViewGroup container,  Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.shopcartfragment, null);
		
		shopcartWebView=(WebView) view.findViewById(R.id.shopcartWebView);
		
		//获取sharedPreferences里面的信息,微信
		sharedPreferences = getActivity().getSharedPreferences("WX_INFO", Context.MODE_PRIVATE);
		wx_token=sharedPreferences.getString("token", "");
		//获取sharedPreferences里面的信息,普通登陆
		sharedPreferences = getActivity().getSharedPreferences("Normal_Info",Context.MODE_PRIVATE);
		nor_token=sharedPreferences.getString("NORMAL_Token", "");
		if(!(""==wx_token)){
			token=wx_token;
		}else if(!(""==nor_token)){
			token=nor_token;
		}else{
			token="";
		}

		if(!TextUtils.isEmpty(token)){
			intent =new Intent(getActivity(),ShopActivity.class);
			startActivity(intent);
			getActivity().finish();
		}else{
			intent =new Intent(getActivity(),LoginActivity.class);
			startActivity(intent);
		}
			
		

	
		return view;
	   
	
	
	}
	
	
	
}